package likou.jindian;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2021/01/26 09:25
 */
public class _10_05 {
    public static void main(String[] args) {
        System.out.println(findString(new String[]{"DirNnILhARNS hOYIFB", "SM ", "YSPBaovrZBS", "evMMBOf", "mCrS", "oRJfjw gwuo", "xOpSEXvfI"},"mCrS"));
    }
    public static int findString(String[] words, String s) {
        int right = words.length-1;
        int left = 0;
        while(right>=left){
            int mid = left+(right-left)/2;
            while(words[mid].isEmpty() && mid>left){
                mid--;
            }
            if(mid==left){
                mid = left+(right-left)/2;
                while(words[mid].isEmpty() && mid<right){
                    mid++;
                }
            }
            if(words[mid].equals(s)) return mid;
            if(words[mid].compareTo(s)>0){
                right= mid-1;
            }else{
                left = mid+1;
            }
        }
        return -1;
    }
}
